package com.breeze.tank;

import java.io.IOException;
import java.util.Properties;

/**
 * Created by Breeze on 2020/8/31
 */
public class PropertyMgr {

    //饿汉式单例
    private static final PropertyMgr INSTANCE = new PropertyMgr();

    private PropertyMgr() {}

    public PropertyMgr getInstance() {
        return INSTANCE;
    }

    static Properties properties = new Properties();

    static {
        try {
            properties.load(PropertyMgr.class.getClassLoader().getResourceAsStream("config"));
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public static Object get(String key) {
        if (properties == null) {
            return null;
        }
        return properties.get(key);
    }

    public static void main(String[] args) {
        System.out.println(PropertyMgr.get("initTankCount"));
    }

}
